var ToolLayer = cc.Layer.extend({
	scene:null,
	ctor:function (parent) {
		this._super();
		this.scene = parent;
		this.scene.addChild(this, 20);
		this.init();
	},
	init: function (){
		var lib = new Angel(this,
				"#button/lib.png",
				this.callback,this);
		lib.setTag(TAG_BUTTON_LIB);
		lib.setPosition(gg.width - lib.width * 0.5 - 10, gg.height * 0.6);
		
		var chapter = new Angel(this,
				"#button/chapter.png",
				this.callback,this);
		chapter.setTag(TAG_BUTTON_CHAPTER);
		chapter.down(lib, 10);
	},
	hiddleLib:function(){
		this.getChildByTag(TAG_BUTTON_LIB).setVisible(false);
		this.getChildByTag(TAG_BUTTON_LIB).setEnable(false);
	},
	showLib:function(){
		this.getChildByTag(TAG_BUTTON_LIB).setVisible(true);
		this.getChildByTag(TAG_BUTTON_LIB).setEnable(true);
	},
	hiddleChapter:function(){
		this.getChildByTag(TAG_BUTTON_CHAPTER).setVisible(false);
	},
	showChapter:function(){
		if(gg.teach_type == TAG_LEAD){
			this.getChildByTag(TAG_BUTTON_CHAPTER).setVisible(true);
		}
	},
	chapterSel:/**
				 * 按钮显示章节选择
				 */
	function(){
		this.getChildByTag(TAG_BUTTON_CHAPTER).setSpriteFrame("button/chapter.png");
	},
	callback: function(pSender) {
		pSender.setEnable(false);
		switch (pSender.getTag()){
			case TAG_BUTTON_LIB:
				if(ll.run.lib.isOpen()){
					ll.run.lib.close();
				} else {
					ll.run.lib.open();
					if(gg.flow.flow.tag == TAG_BUTTON_LIB){
						gg.flow.next();
					}
				}
				break;
			case TAG_BUTTON_CHAPTER:
				if(ll.select != null){
					ll.run.setVisible(true);
					ll.tip.arr.showArr(true);
					this.getParent().destroySelect();
					pSender.setSpriteFrame("button/chapter.png");
				} else {
					ll.run.setVisible(false);
					ll.tip.arr.hiddleArr();
					this.getParent().loadSelect2();	
					pSender.setSpriteFrame("button/chapter_cancel.png");
				}
				break;
		}
		pSender.setEnable(true);
	}
})